Add an api to parse shortcut actions
authorMatthias Clasen <mclasen@redhat.com>
Sat, 4 Apr 2020 02:41:15 +0000 (22:41 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 4 Apr 2020 02:41:15 +0000 (22:41 -0400)
This is so we can test this code. While doing it
I also fixed the missing else that was caused it
not to work.

gtk/gtkshortcutaction.c
gtk/gtkshortcutaction.h

index 176fe5fa5a9b3cf381af65c4c6a939a928e929f6..c1357d04e885d4935a86fd55e3f2e84a8f9896a3 100644 (file)
 *  - #GtkNamedAction: a shortcut action that calls gtk_widget_activate_action()
 *  - #GtkGActionAction: a shortcut action that activates a given #GAction
 *  - #GtkNothingAction: a shortcut action that does nothing
+*
+* # GtkShortcutAction as GtkBuildable
+*
+* GtkShortcut
 */
 
 #include "config.h"
@@ -180,9 +184,7 @@ string_is_function (const char *string,
 }
 
 GtkShortcutAction *
-gtk_shortcut_action_parse_builder (GtkBuilder  *builder,
-                                   const char  *string,
-                                   GError     **error)
+gtk_shortcut_action_parse_string (const char *string)
 {
   GtkShortcutAction *result;
   char *arg;
@@ -204,6 +206,22 @@ gtk_shortcut_action_parse_builder (GtkBuilder  *builder,
       result = gtk_signal_action_new (arg);
       g_free (arg);
     }
+  else
+    return NULL;
+
+  return result;
+}
+
+GtkShortcutAction *
+gtk_shortcut_action_parse_builder (GtkBuilder  *builder,
+                                   const char  *string,
+                                   GError     **error)
+{
+  GtkShortcutAction *result;
+
+  result = gtk_shortcut_action_parse_string (string);
+
+  if (!result)
     {
       g_set_error (error,
                    GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_INVALID_VALUE,
index d59934492294d2b620ade9677d8b73ae2c294798..2fa276032406d009211bd64d2b70b7471763fd54 100644 (file)
@@ -60,6 +60,9 @@ GDK_DECLARE_INTERNAL_TYPE (GtkShortcutAction, gtk_shortcut_action, GTK, SHORTCUT
 
 GDK_AVAILABLE_IN_ALL
 char *                  gtk_shortcut_action_to_string           (GtkShortcutAction      *self);
+GDK_AVAILABLE_IN_ALL
+GtkShortcutAction *     gtk_shortcut_action_parse_string        (const char *            string);
+
 GDK_AVAILABLE_IN_ALL
 void                    gtk_shortcut_action_print               (GtkShortcutAction      *self,
                                                                  GString                *string);